<?php
/**
 * Created by PhpStorm.
 * User: 123
 * Date: 2020/9/2
 * Time: 13:39
 */

namespace app\admin\controller;

use app\service\StatisticalService;
use app\service\SupplierService;
use think\Db;

/**
 * 数据中心.
 * @author   juzi
 * @blog    https://blog.csdn.net/juziaixiao
 * @version  0.0.1
 * @datetime 2020年7月22日10:57:35
 */
class Datacenter extends Common
{
    /**
     * 构造方法.
     * @author   juzi
     * @blog     https://blog.csdn.net/juziaixiao
     * @version  1.0.0
     * @datetime 2020年7月22日10:57:59
     */
    public function __construct()
    {
        // 调用父类前置方法
        parent::__construct();

    }

    /**
     * 首页.
     * @author   juzi
     * @blog     https://blog.csdn.net/juziaixiao
     * @version  1.0.0
     * @datetime 2020年7月22日10:57:59
     */
    public function Index()
    {


            $data=[];
            //供应商入住
            $where = SupplierService::supListWhere(['from_client'=>2,'audit_status'=>1]);
            $supplier_num= SupplierService::DataTotal('supplier',$where);

            $this->assign('supplier_num', $supplier_num);

            //用户总量
            $user = StatisticalService::UserYesterdayTodayTotal();

            $this->assign('user', $user['data']);
//
            // 订单总数
            $order_number = StatisticalService::OrderNumberYesterdayTodayTotal();
            $this->assign('order_number', $order_number['data']);
        //dump($order_number);exit;

            // 销售总计
            $order_complete_money = StatisticalService::OrderCompleteMoneyYesterdayTodayTotal();
            $this->assign('order_complete_money', $order_complete_money['data']);
            //注册统计
            $user_reg=StatisticalService::UserRegTotal();
            //$user_reg=count($user_reg)>10?array_slice($user_reg,0,10):$user_reg;

           // exit;
            $this->assign('user_reg', $user_reg[0]);

            return $this->fetch();


    }

    /**
     * 用户注册数据.
     * @author   juzi
     * @blog     https://blog.csdn.net/juziaixiao
     * @version  1.0.0
     * @datetime 2020年7月22日10:57:59
     */
    public function UserRegList(){
        if ('ajax' != input('get.action')) {
            return $this->fetch();
        } else {
            $user_reg=StatisticalService::UserRegTotal();

            $total = $user_reg[1];

            return ['code' => 0, 'msg' => '', 'count' => $total, 'data' => $user_reg[0]];
        }

    }
}